#pragma once

#include <time.h>
#include "..\DXG\DXViewEntity.h"
#include "..\DXG\DXMesh.h"
#include "House.h"
#include "Mountain.h"
#include "Tree.h"
#include "Map.h"
#include "..\GEntity\Miner.h"

#define MAX_HOUSE 24
#define MAX_MOUNTAIN 24
#define MAX_TREE 6

enum Locations
{
	Shack,
	GoldMine,
	Bank,
	Bar,
	Unknown = ~0U
};

class GWorld : public DXViewEntity
{
private:
	Map m_map;

	DXMesh m_mesh;

	House m_houses[MAX_HOUSE];

	Mountain m_mountains[MAX_MOUNTAIN];

	Tree m_trees[MAX_TREE];

	Miner m_miner;

public:
	GWorld(void);
	virtual ~GWorld(void);

	void Init();

	virtual HRESULT Draw(LPDIRECT3DDEVICE9 pd3ddev9);

	time_t GetGWorldTime();

	HRESULT CreateMapMesh(LPDIRECT3DDEVICE9 pd3ddev9);

	D3DXVECTOR3 GetAreaVector(int ax, int ay);

	POINTU GetArea(D3DXVECTOR3 vec);

	int FindRoute(POINTU from, POINTU to, std::list<POINTU>* pRoute) const
	{
		return m_map.FindRoute(from, to, pRoute);
	}

	int FindRoute(Locations from, Locations to, std::list<POINTU>* pRoute) const
	{
		return m_map.FindRoute(GetPoint(from), GetPoint(to), pRoute);
	}

	POINTU GetPoint(Locations) const;
};

extern GWorld* pWorld;